import { Component, OnInit } from '@angular/core';
import { ContrastInfoService } from './contrast-info.service';
import * as flatpickr from 'flatpickr';
import { zh } from "flatpickr/dist/l10n/zh.js";
import * as _ from "lodash";
import { environment } from "../../../../../../environments/environment";
@Component({
  selector: 'app-contrast-info',
  templateUrl: './contrast-info.component.html',
  styleUrls: ['./contrast-info.component.scss'],
  providers: [ContrastInfoService]
})
export class ContrastInfoComponent implements OnInit {

  public getBody = {
    date: ''
  }
  constructor(
    public contrastInfoService: ContrastInfoService
  ) { }


  ngOnInit() {
    // 初始化日期控件
    flatpickr.localize(zh);
  }

  // 导出数据
  exportExcel() {
   if(this.getBody.date!==''){
    let downloadURL = '/pms/1/riskmanage/exportLatestComparison?token=' + sessionStorage.getItem('token') + '&date='+this.getBody.date;
    // 下载
    let iframe = window['$']("<iframe id='downloadiframe'>");
    iframe.attr('style', 'display:none');
    iframe.attr('src', environment.server + downloadURL);
    window['$']('body').append(iframe);
    setTimeout("$('#downloadiframe').remove()", 60000);
   }
   else{
    window['swal']("提示", "请选择日期后再导出", "warning")
   }
  }

}
